<include file="../header" />
<div id="left-sider"><include file="../left-sider" /></div>
<style type="text/css">
.main-bd > div {
	margin-bottom: 30px;
	padding: 10px;
	border-bottom: 1px dotted #999;	
}
textarea {
	width: 100%;
	height: 250px;	
}
#brochure {
	width: 250px;	
}
</style>
<div id="main">
	<div class="main-hd">
		<h2>Sponsorship</h2>
	</div>
	<div class="main-bd">
		<div>
			<form method="post" target="_self" action="general">
				<h3>简介</h3>
				<p class="help">赞助商页面开始的基本信息(General Information)</p>
				<table width="100%" border="0">
					<tr>
						<th scope="col">简体中文</th>
						<th scope="col">English</th>
					</tr>
					<tr>
						<td><textarea name="sponsorship_zh-cn">{$general['zh-cn']}</textarea></td>
						<td><textarea name="sponsorship_en-us">{$general['en-us']}</textarea></td>
					</tr>
				</table>
				<p class="text-center">
					<input type="submit" value="更新"/>
				</p>
			</form>
		</div>
		<div>
			<form method="post" target="_self" action="brochure">
				<h3>小册子</h3>
				<p class="help">
					点击“Become a Sponsor”时下载的文件
				</p>
				<p>
					<label for="brochure">Brochure:</label>
					<input type="text" name="brochure" value="{$brochure}" id="filepath" readonly="readonly"/>
					<input type="button" class="uploadBtn" value="上传" lang="filepath"/>
					<input type="submit" value="更新"/>
				</p>
			</form>
		</div>
		<div>
		<form id="sponsorToDelForm" action="remove" method="post" target="_self">
			<h3>赞助商列表</h3>
			<p class="help">显示在赞助商页面后半部分</p>
			<div>
				<p>
					<input type="submit" value="删除" />
					<a href="create">新增</a></p>
			</div>
			<div>
				<table width="100%" border="1" class="table-list">
					<tr>
						<th><input type="checkbox" id="sponsorToDelCtrl"/></th>
						<th>Content</th>
						<th>Type</th>
						<th>Language</th>
						<th>Option</th>
					</tr>
					<volist name="sponsors" id="sponsor">
						<tr>
							<td class="text-center"><input class="sponsorToDel" type="checkbox" name="sponsorToDel[]" value="{$sponsor.id}"/></td>
							<td>{$sponsor.content|strip_tags|String::msubstr=0,30,"utf-8",true}</td>
							<td>{$sponsor.type}</td>
							<td>{$sponsor.lang}</td>
							<td><a href="edit/id/{$sponsor.id}" target="_self">编辑</a></td>
						</tr>
					</volist>
				</table>
			</div>
			</div>
			<input name="t" type="hidden" value="del" />
		</form>
	</div>
</div>
</div>
<include file="../footer" />
<import type="js" file="js.jquery"/>
<import type="js" file="js.xheditor"/>
<script type="text/javascript">
$('textarea').xheditor({tools:'Bold,Italic,|,List,Fontface,FontSize,FontColor,Img,|,Removeformat,Source,|,Fullscreen', upImgUrl:"../Upload/ajax_pic",upImgExt:"jpg,jpeg,gif,png",html5Upload:false, width: '100%'});

var sponsorToDel = document.querySelectorAll('.sponsorToDel');
document.getElementById('sponsorToDelCtrl').addEventListener('click',function(){
		if(this.checked) {
			for(var i=0; i<sponsorToDel.length; i++) {
				sponsorToDel[i].checked = true;
			}
		} else {
			for(var i=0; i<sponsorToDel.length; i++) {
				sponsorToDel[i].checked = false;
			}
		}
}, false);

document.getElementById('sponsorToDelForm').addEventListener('submit',function(e){
		if(!confirm('删除后无法恢复，你是否要继续？')) {
				e.preventDefault();
				return false;
		}
}, false);

$('.uploadBtn').click(function(){
    window.open("{:U('Upload/brochure')}?prefix=&cbi="+this.lang);
});
</script>